/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.allscore.cloud.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * @author Administrator
 */
@SpringBootApplication
public class RouterApp {

    public static void main(String[] args) {
        SpringApplication.run(RouterApp.class, args);
    }

//    @Bean
//    public RouteLocator helloRouteLocator(RouteLocatorBuilder builder) {
//        return builder.routes()
//                .route(t -> t.path("/hello").filters(f ->
//                                f.addResponseHeader("X-AnotherHeader", "baz"))
//                .uri("http://localhost:9000"))
//                .build();
//    }
//    
//    @Bean
//    public RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
//        return builder.routes()
//                .route(t -> t.path("/test")
//                .and()
//                .uri("http://localhost:9000"))
//                .build();
//    }

//    @Bean
//    public RouterFunction<ServerResponse> testFunRouterFunction() {
//        RouterFunction<ServerResponse> route = RouterFunctions.route(
//                RequestPredicates.path("/test"),
//                request -> ServerResponse.ok().body(BodyInserters.fromObject("TestRouter")));
//        return route;
//    }

}
